﻿using System;
using System.Collections.Generic;
using Glue;
using Xunit;

namespace GlueExamples
{
    public class MappingLists
    {
        public class Article
        {
            public String Title { get; set; }
            public String Text { get; set; }
        }

        public class ArticleDTO
        {
            public String Title { get; set; }
            public String Text { get; set; }
        }

        [Fact]
        public void DoIt()
        {
            IList<Article> articles = new List<Article>()
                                              {
                                                  new Article { Title = "1", Text = "abc" }, 
                                                  new Article { Title = "2", Text = "abc" }, 
                                                  new Article { Title = "3", Text = "abc" }
                                              };

var mapper = new Mapping<Article, ArticleDTO>();
mapper.AutoRelateEqualNames();
IList<ArticleDTO> articleDTOs = new List<ArticleDTO>();
foreach (var article in articles)
{
    articleDTOs.Add(mapper.Map(article));
}
            
            Assert.Equal(3,articleDTOs.Count);
            Assert.True(articleDTOs[0].Title == "1");
            Assert.True(articleDTOs[1].Title == "2");
            Assert.True(articleDTOs[2].Title == "3");
        }
    }
}
